package com.bean;

import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionBindingListener;

public class Person implements HttpSessionBindingListener {
    private int age;
    private String sex;
    private String name;

    public Person() {
    }

    @Override
    public void valueBound(HttpSessionBindingEvent event) {
        //当前类对象 被添加到Session域中时，会被调用
        System.out.println("Person对象 被添加到Session中：" + event.getName() + "VALUE:" + event.getValue());
    }

    @Override
    public void valueUnbound(HttpSessionBindingEvent event) {
        //当前类对象 被移除出Session域中时，会被调用
        System.out.println("Person对象 被移除出Session中：" + event.getName() + "VALUE:" + event.getValue());
    }

    @Override
    public String toString() {
        return "Person{" +
                "age=" + age +
                ", sex='" + sex + '\'' +
                ", name='" + name + '\'' +
                '}';
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
